﻿using GrainManage.Entities;
using System;
using System.Reflection;

namespace GrainManage.Server
{
    public static class ExtensionClass
    {
        public static void PermissionID(this BaseInputModel baseInput, int permissionID)
        {
            if (baseInput != null)
            {
                Type t = typeof(BaseInputModel);
                FieldInfo field = t.GetField("permissionID", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.IgnoreCase | BindingFlags.ExactBinding);
                if (field != null)
                {
                    field.SetValue(baseInput, permissionID);
                }
            }
        }

        public static int PermissionID(this BaseInputModel baseInput)
        {
            int permissionID = 0;
            if (baseInput != null)
            {
                Type t = typeof(BaseInputModel);
                FieldInfo field = t.GetField("permissionID", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.IgnoreCase | BindingFlags.ExactBinding);
                if (field != null)
                {
                    object obj = field.GetValue(baseInput);
                    permissionID = Convert.ToInt32(obj);
                }
            }
            return permissionID;
        }
    }
}